package com.tedu.egmybatis1.mapper;

import com.tedu.egmybatis1.pojo.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper {
   @Insert("insert  into product(title,price,stock)VALUES (#{title},#{price},#{stock})")
    int insert(Product record);

   @Select("select  id,title,price,stock FROM  product WHERE id=#{id}")
    Product selectById(int id);

   @Delete("delete  from  product WHERE id=#{id}")
   int deleteById(int id);

   @Select("SELECT id,title,price,stock FROM product")
    List<Product> selectAll();
}
